<?php 
	$this->assign('button_save_template','<a href="javascript:void(0)" class="btn btn-sm btn-info" onclick="ShowModel();"><i class="fa fa-fw fa-plus"></i> NEW TEMPLATE</a>');
    $this->Html->css(array('font', 'app.v2','custom'), array('inline' => false));
    $this->Html->script(array('app.v2'), array('inline' => false));
	$this->Html->script(array('datepicker/bootstrap-datepicker',
		'charts/flot/jquery.flot.min',
		'charts/flot/jquery.flot.tooltip.min',
		'charts/flot/jquery.flot.resize',
		'charts/flot/jquery.flot.orderBars',
		'charts/flot/jquery.flot.pie.min',
		'charts/flot/demo'), array('inline' => false));
?>
<section id="content">
	<section class="main padder">
		<div class="clearfix">
			<h4>
			     Dashboard
			</h4>
		</div>
            <section class="panel col-lg-12">
                <div class="clearfix">
                    <h4>
                        <i class="fa fa-home"></i>
                        <a href="admin"><span>Home</span></a>
                        <i class="fa fa-angle-right"> Dashboard</i>
                    </h4>
                    
                </div>
            </section>
		<div class="row">
            <div class="col-lg-12">
                    <section class="panel">
                        <header class="panel-heading">Report Panel </header>
                        <div class="panel-body">
                            <div class="row text-small">
                                <div class="col-sm-4 m-b-mini">
                                    
                                </div>
                                <div class="col-sm-4 m-b-mini">
                                    <div class="block">
                                        <div class="btn-group">
                                            <button id="abc" type="button" class="btn" onclick="inday();">Day</button>
                                            <button id="week" type="button" class="btn " onclick="inweek();">Week</button>
                                            <button id="month" type="button" class="btn " onclick="inmonth();">Month</button>
                                            <button id="year" type="button" class="btn " onclick="inyear();">Year</button>
                                            <button id="all" type="button" class="btn " onclick="getall();">Total</button>
                                        </div>
                                    </div>
                                </div>
                                
                                    <div class="col-sm-4 m-b-mini">
                                        <div class="input-group">
                                            <input class="form-control datepicker" onchange="searchreport();" type="text" style="width: 100%; height: 34px" data-date-format="dd-mm-yyyy" value="12-02-2013" size="16">
                                            <span class="input-group-btn">
                                                <button  class="btn btn-inverse" type="button" onclick="searchreport();">Go!</button>
                                            </span>
                                            </div>
                                        </div>
                                    </div>
                                
                        </div>
                        <div class="table-responsive">
                        <div class="col-lg-12"> &nbsp;</div>
                            <table class="table table-striped b-t text-small">
                                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                                    <section id="revenue" class="panel">
                                        <div class="panel-body text-center">
                                            <div class="row">
                                                <div class="left">
                                                    <?php echo $this->Html->image('revenue.png',array('alt'=>'ALT','style'=>array('width: 60px;' , 'height: 70px' ))); ?>
                                                </div>
                                                <div class="right detail">
                                                    <div class="number"><?php echo $revenueAll[0][0]["revenue"]; ?>$</div>
                                                    <div class="desc">Total Profit</div>
                                                </div>
                                            </div>
                                        </div>
                                        <a href="#Revenue"><header class="panel-heading">View more</header></a>
                                    </section>
                                </div>
                                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                                    <section class="panel">
                                        <div class="panel-body text-center">
                                            <div class="row">
                                                <div class="left">
                                                    <?php echo $this->Html->image('cart.png',array('alt'=>'ALT','style'=>array('width: 60px;' , 'height: 70px' ))); ?>
                                                </div>
                                                <div class="right detail">
                                                    <div class="number"><?php echo $countPricing[0][0]["count"]; ?></div>
                                                    <div class="desc">New pricing</div>
                                                </div>
                                            </div>
                                        </div>
                                        <a href="admin/subscriptions"><header class="panel-heading">View more</header></a>
                                    </section>
                                </div>
                                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                                    <section class="panel">
                                        <div class="panel-body text-center">
                                            <div class="row">
                                                <div class="left">
                                                <?php echo $this->Html->image('user.png',array('alt'=>'ALT','style'=>array('width: 60px;' , 'height: 70px' ))); ?>
                                                </div>
                                                <div class="right detail">
                                                   <div class="number"><?php echo $countUser[0][0]["count"]?></div>
                                                    <div class="desc">New user</div>
                                                </div>
                                            </div>
                                        </div>
                                        <a href="admin/users"><header class="panel-heading">View more</header></a>
                                    </section>
                                </div>
                                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                                    <section class="panel">
                                        <div class="panel-body text-center">
                                            <div class="row">
                                                <div class="left">
                                                 <?php echo $this->Html->image('template.png',array('alt'=>'ALT','style'=>array('width: 60px;' , 'height: 70px' ))); ?>
                                                </div>
                                                <div class="right detail">
                                                    <div class="number"><?php echo $countTemplate[0][0]["count"]?></div>
                                                    <div class="desc">New template</div>
                                                </div>
                                            </div>
                                        </div>
                                        <a href="admin/templates">
                                            <header class="panel-heading">View more</header></a>
                                    </section>
                                </div>
                            </table>
                        </div>
                    </section>
                </div>
		</div>
		<div class="row">
			<div class="col-lg-4">
                    <section class="panel">
                        <header class="panel-heading">Pricing</header>
                        <div class="panel-body text-center">
                            <div class="sparkline inline" data-type="pie" data-height="175" data-slice-colors="['#3fcf7f','#ff5f5f','#f4c414','#233445']">
                                <?php echo $this->Number->precision($resultYear,2); ?>,
                                <?php echo $this->Number->precision($resultFree,2); ?>,
                                <?php echo $this->Number->precision($resultMonth,2); ?>,
                                <?php echo $this->Number->precision($resultExpi,2); ?>,</div>
                            <div class="line pull-in"></div>
                            <div class="text-mini">
                                <i class="fa fa-circle text-success"></i>Yearly
                                <i class="fa fa-circle text-danger"></i>Free
                                <i class="fa fa-circle text-warning"></i>Monthly 
                                <i class="fa fa-circle text-info"></i>Expiration
                                <span> Total: <?php echo $allPricing; ?> pricing</span></div>
                        </div>
                    </section>
            </div> 
            <div class="col-lg-8">
            	<section class="panel">
                        <header class="panel-heading">Template history</header>
                        <div class="panel-body text-center">
                            <div class="inline">
                                <div class="sparkline inline" data-type="bar" data-height="145" data-bar-width="30" data-bar-spacing="10" data-bar-color="#a3e2fe"  data-composite-fill-color="#f3fce3" data-highlight-line-color="#e1e5e9" data-spot-radius="3">
                                    <?php foreach($topTemplates as $topTemplate)
                                            { 
                                            echo $topTemplate["med_tem"]["soluong"]; 
                                        ?>
                                        , 
                                            <?php

                                            }?></div>
                                <ul class="list-inline text-muted axis cus-li">
                                    <?php foreach($topTemplates as $topTemplate)
                                            { ?>
                                            <li>
                                        <?php
                                            echo $topTemplate["tem"]["name"]; ?><br>
                                            <?php
                                            echo $this->Number->precision($topTemplate["0"]["phantram"],2); ?>%
                                        </li>
                                            <?php
                                            }?>
                                </ul>
                            </div>
                            <div class="line pull-in"></div>
                            <div class="text-small">Check more data</div>
                        </div>
                </section>
            </div>
		</div>
		<div class="row">
			<div class="col-lg-4">
	            <section id="Revenue" class="panel" style="height:300px">
	                <header class="panel-heading">Revenue</header>
	                <div class="panel-body">
	                    <div class="media">
	                        <div class="pull-right media-small">Today</div>
	                        <div class="progress bg-light">
	                            <div class="progress-bar bg-primary" style="width: 65%">$<?php echo $revenueInday[0][0]["revenue"]; ?></div>
	                        </div>
	                    </div>
	                    <div class="media m-t-none">
	                        <div class="pull-right media-small">Yesterday</div>
	                        <div class="progress bg-light">
	                            <div class="progress-bar bg-success" style="width: 80%">$<?php echo $revenueInyesterday[0][0]["revenue"]; ?></div>
	                        </div>
	                    </div>
	                    <div class="media m-t-none">
	                        <div class="pull-right media-small">Friday</div>
	                        <div class="progress bg-light">
	                            <div class="progress-bar bg-info" style="width: 60%">$<?php $revenueInFri[0][0]["revenue"];?> </div>
	                        </div>
	                    </div>
	                    <div class="media m-t-none">
	                        <div class="pull-right media-small">Thursday</div>
	                        <div class="progress bg-light">
	                            <div class="progress-bar bg-warning" style="width: 55%">$<?php $revenueInThur[0][0]["revenue"];?></div>
	                        </div>
	                    </div>
	                    <div class="media m-t-none">
	                        <div class="pull-right media-small">Wednesday</div>
	                        <div class="progress bg-light">
	                            <div class="progress-bar bg-danger" style="width: 50%">$<?php $revenueInWed[0][0]["revenue"];?></div>
	                        </div>
	                    </div>
	                    <div class="media m-t-none">
	                        <div class="pull-right media-small">Tuesday</div>
	                        <div class="progress bg-light">
	                            <div class="progress-bar bg-default" style="width: 35%">$<?php $revenueInTue[0][0]["revenue"];?></div>
	                        </div>
	                    </div>
	                    <div class="media m-t-none">
	                        <div class="pull-right media-small">Monday</div>
	                        <div class="progress bg-light">
	                            <div class="progress-bar bg-default" style="width: 40%">$<?php echo $revenueInMon[0][0]["revenue"]; ?></div>
	                        </div>
	                    </div>
	                </div>
	            </section>
	        </div>
	        <div class="col-md-8">
                <section class="panel" style = "height:300px">
                    <header class="panel-heading">
                        <ul class="nav nav-pills pull-right">
                            <li><a href="javascript:void(0)" data-loading-text="loading..."><i class="fa fa-retweet"></i></a></li>
                            <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="text">Day</span> <span class="caret"></span></a>
                                <ul class="dropdown-menu pull-right">
                                    <li class="active"><a href="#">Day</a></li>
                                    <li><a href="#">Week</a></li>
                                    <li><a href="#">Month</a></li>
                                </ul>
                            </li>
                        </ul>
                        <span>Snapshot</span> </header>
                    <ul class="list-group">
                        <li class="list-group-item">
                            <div class="media">
                                <div class="pull-left text-center media-large">
                                    <div class="h4 m-t-mini"><strong>Free</strong></div>
                                    <small class="text-muted">Template used</small> </div>
                                <div class="pull-right hidden-sm text-right m-t"><b class="badge bg-info" data-toggle="tooltip" data-title="Free"><?php echo $countFree; ?></b> </div>
                                <div class="media-body">
                                    <div class="sparkline" data-type="bar" data-bar-color="#8e98a9" data-bar-width="30" data-height="28">   
                                        <?php foreach($topTemFrees as $topTemFree)
                                            { 
                                            echo $topTemFree["med_tem"]["soluong"]; 
                                        ?>
                                        ,
                                            <?php

                                            }?>
                                        
                                    </div>
                                    <ul class="list-inline text-muted axis">
                                        <?php foreach($topTemFrees as $topTemFree)
                                            { ?>
                                            <li data-toggle="tooltip" data-title= "Creator: <?php echo $topTemFree['u']['username']; ?>">
                                        <?php
                                            echo $topTemFree["tem"]["name"]; ?>
                                        </li>
                                            <?php
                                            }?>
                                    </ul>
                                </div>
                            </div>
                        </li>
                        <li class="list-group-item">
                            <div class="media">
                                <div class="pull-left text-center media-large">
                                    <div class="h4 m-t-mini"><strong>Month</strong></div>
                                    <small class="text-muted">Template used</small> </div>
                                <div class="pull-right hidden-sm text-right m-t"><b class="badge bg-success" data-toggle="tooltip" data-title="Monthly"><?php echo $countMonth; ?></b> </div>
                                <div class="media-body">
                                    <div class="sparkline" data-type="bar" data-bar-color="#13c4a5" data-bar-width="30" data-height="28">
                                         <?php foreach($topTemMonths as $topTemMonth)
                                            { 
                                            echo $topTemMonth["med_tem"]["soluong"]; 
                                        ?>
                                        ,
                                            <?php

                                            }?>
                                        
                                    </div>
                                    <ul class="list-inline text-muted axis">
                                        <?php foreach($topTemMonths as $topTemMonth)
                                            { ?>
                                            <li data-toggle="tooltip" data-title= "Creator: <?php echo $topTemMonth['u']['username']; ?>">
                                        <?php
                                            echo $topTemMonth["tem"]["name"]; ?>
                                        </li>
                                            <?php
                                            }?>
                                    </ul>
                                </div>
                            </div>
                        </li>
                        <li class="list-group-item">
                            <div class="media">
                                <div class="pull-left text-center media-large">
                                    <div class="h4 m-t-mini"><strong>Year</strong></div>
                                    <small class="text-muted">Template used</small> </div>
                                <div class="pull-right hidden-sm text-right m-t"><b class="badge" data-toggle="tooltip" data-title="Yearly"><?php echo $countYear;?></b> </div>
                                <div class="media-body">
                                    <div class="sparkline" data-type="bar" data-bar-color="#61a1e1" data-bar-width="30" data-height="28">
                                        <?php foreach($topTemYears as $topTemYear)
                                            { 
                                            echo $topTemYear["med_tem"]["soluong"]; 
                                        ?>
                                        ,
                                            <?php

                                            }?>
                                    </div>
                                    <ul id="tool" class="list-inline text-muted axis">
                                        <?php foreach($topTemYears as $topTemYear)
                                            { ?>
                                            <li data-toggle="tooltip" data-title= "Creator: <?php echo $topTemYear['u']['username']; ?>">
                                        <?php
                                            echo $topTemYear["tem"]["name"]; ?>
                                        </li>
                                            <?php
                                            }?>
                                    </ul>
                                </div>
                            </div>
                        </li>
                    </ul>
                </section>
            </div>
		</div>
	</section>
</section>